package daybook.io.args;

import com.beust.jcommander.IParameterValidator;
import com.beust.jcommander.ParameterException;

import java.util.Arrays;
import java.util.List;

public class LogLevelValidator implements IParameterValidator {
    private static final List<String> VALID_LOG_LEVEL = Arrays.asList(
            "ALL", "TRACE", "DEBUG", "INFO", "WARN", "ERROR", "OFF");

    @Override
    public void validate(String name, String value) throws ParameterException {
        if (!VALID_LOG_LEVEL.contains(value.toUpperCase())) {
            throw new ParameterException("invalid log level: " + value);
        }
    }
}
